package com.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;

/**
 * @description: 启动一个流程实例 前提定义好一个流程实例
 * @author: guoc
 * @createDate: 2020/9/9 17:43
 */
public class activitiStart {

    @Test
    public void startProcessInstance(){
        //获取ProcessEngine
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        // 获取RunTimeService
        RuntimeService runtimeService = defaultProcessEngine.getRuntimeService();

        // 根据流程定义key启动流程 需要知道key  //myProcess_1
        ProcessInstance holiday = runtimeService.startProcessInstanceByKey("test");

        System.out.println("流程部署ID"+holiday.getDeploymentId());
        System.out.println("实例ID"+holiday.getId());
        System.out.println("活动ID"+holiday.getActivityId());
    }

}
